﻿
namespace MVVMBasedDialogs.ViewModel
{
    using GalaSoft.MvvmLight;
    using System.Windows.Input;
    using GalaSoft.MvvmLight.Command;
    using GalaSoft.MvvmLight.Messaging;
    using System.Windows;

    /// <summary>
    /// This class contains properties that the main View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// You can also use Blend to data bind with the tool's support.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm/getstarted
    /// </para>
    /// </summary>
    public class MainViewModel : ViewModelBase
    {
        public string Welcome
        {
            get
            {
                return "Dialogs & MVVM";
            }
        }

        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
            }
            else
            {
                // Code runs "for real"
            }
        }

        ////public override void Cleanup()
        ////{
        ////    // Clean up if needed

        ////    base.Cleanup();
        ////}

        ICommand _showDialogCommand;
        public ICommand ShowDialogCommand
        {
            get
            {
                if (_showDialogCommand == null)
                {
                    _showDialogCommand = new RelayCommand(
                        () =>
                        {
                            //var message = new NotificationMessage("Not so hard!");
                            var message = new DialogMessage("Notification Message", null)
                            {
                                Caption = "test",
                                Button = MessageBoxButton.OK
                                
                            };

                            Messenger.Default.Send(message);
                        }
                        );                    
                }

                return _showDialogCommand;
            }
        }

        private void DialogMessageCallback(MessageBoxResult result)
        {
            //if (result == MessageBoxResult.OK)
            //{
            //    Message = "Continue";
            //}
            //else
            //{
            //    Message = "Stop";
            //}
        }
    }
}